<?php 

  //--------------------------------------------------------------------------
  // Example php script for fetching data from mysql database
  //--------------------------------------------------------------------------
 

  //--------------------------------------------------------------------------
  // 1) Connect to mysql database
  //--------------------------------------------------------------------------
  include 'DB.php';
  $con = mysql_connect($host,$user,$pass);
  $dbs = mysql_select_db($databaseName, $con);

  //--------------------------------------------------------------------------
  // 2) Query database for data

  $result = mysql_query("SELECT * FROM $tableName");          //query


  //--------------------------------------------------------------------------
while($row = mysql_fetch_row($result)){
$table_data[] = array("id" => $row[0] , "nome" => $row[1]);
}
echo json_encode($table_data);
//--------------------------------------------------------------------------
  // 3) echo result as json 
  //--------------------------------------------------------------------------
  
?>